package adventure.placeable;

/**
 *
 * @author Michael Hanns
 *
 */
public class ItemUnlocksImp implements ItemUnlocks, ItemUnlocksEdit {

    private int x;
    private int y;
    private int z;
    private char dir;
    private boolean valid;

    public ItemUnlocksImp(int x, int y, int z, char dir) {
        this.x = x;
        this.y = y;
        this.z = z;
        this.dir = dir;
        this.valid = true;
    }

    public ItemUnlocksImp(int x, int y, int z) {
        this.x = x;
        this.y = y;
        this.z = z;
        this.valid = false;
    }

    @Override
    public void setDir(char d) {
        this.dir = d;
        this.valid = true;
    }

    @Override
    public boolean unlocks(int x, int y, int z, char dir) {
        if (valid && this.x == x && this.y == y && this.z == z & this.dir == dir) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public String getStringRepresentation() {
        return "(" + x + ", " + y + ", " + z + ") : " + dir;
    }

    @Override
    public ItemUnlocks cloneThis() {
        return new ItemUnlocksImp(x, y, z, dir);
    }
}
